package com.example.mapstruct.convert;

import com.example.mapstruct.entity.student.StudentDao;
import com.example.mapstruct.entity.student.StudentModel;
import com.example.mapstruct.entity.student.StudentVO;
import org.mapstruct.Mapper;
import org.mapstruct.Mapping;
import org.mapstruct.factory.Mappers;

@Mapper
public interface StudentConvert {

    /*工厂模式获取实例*/
    StudentConvert INSTANCE = Mappers.getMapper(StudentConvert.class);

    StudentVO dao2vo(StudentDao dao);

    /*自定义转换*/
    @Mapping(target = "studentName",    source = "name")
    @Mapping(target = "studentAge",     source = " age")
    @Mapping(target = "studentAddress", source = "address")
    @Mapping(target = "studentEmail",   source = "email")
    @Mapping(target = "studentPhone",   source = "phone")
    StudentModel dao2model(StudentDao dao);
}
